﻿'Quitado botón borrar
Public Class FormModificarJugador

    Private _miCampeonato As Campeonato
    Private _idJugadorAModificar As Integer

    Property idJuagadorAModificar As Integer
        Get
            Return Me._idJugadorAModificar
        End Get
        Set(value As Integer)
            Me._idJugadorAModificar = value
        End Set
    End Property

    Private Sub FormModificarJugador_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.MdiParent = FormEntrada
        _miCampeonato = New Campeonato()
    End Sub

    Private Sub btnModificarConsulta_Click(sender As Object, e As EventArgs) Handles btnModificarConsulta.Click
        'valido que los tipos de datos sean los correctos
        Dim tieneWhatsapp As Integer
        Dim direccionNumero As Integer
        Dim fecha As Date

        If rbtWhatsAppSi.Checked Then
            tieneWhatsapp = -1
        Else
            tieneWhatsapp = 0
        End If
        If txtNumConsulta.Text = "" Then
            direccionNumero = 0
        Else
            direccionNumero = CInt(txtNumConsulta.Text)
        End If
        If txbFechaNacimieto.Text = "" Then
            fecha = #1/1/1000#
        Else
            fecha = CDate(txbFechaNacimieto.Text)
        End If
        _miCampeonato.actualizarJugador(txtNIFConsulta.Text, txtNombreConsulta.Text, _
                                  txtApellidosConsulta.Text, fecha, txtCalleConsulta.Text, _
                                  direccionNumero, txtPuertaConsulta.Text, _
                                  txtLocalidadConsulta.Text, txtProvinciaConsulta.Text, _
                                  txtCorreoConsulta.Text, tieneWhatsapp, _
                                  txtFacebookConsulta.Text, txtTwitterConsulta.Text, CInt(Me._idJugadorAModificar))
        borrarFormulario()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        FormBuscarJugadores.Show()
        FormBuscarJugadores.formDestino = "FormModificarJugador"
    End Sub

    Private Sub borrarFormulario()
        For Each control As Windows.Forms.Control In Me.Controls
            If TypeOf control Is GroupBox Then
                For Each controlText As Windows.Forms.Control In Me.GroupBox1.Controls
                    If TypeOf controlText Is TextBox Then
                        CType(controlText, TextBox).Clear()
                    End If
                Next
                For Each controlText As Windows.Forms.Control In Me.GroupBox2.Controls
                    If TypeOf controlText Is TextBox Then
                        CType(controlText, TextBox).Clear()
                    End If
                Next
                For Each controlText As Windows.Forms.Control In Me.GroupBox3.Controls
                    If TypeOf controlText Is TextBox Then
                        CType(controlText, TextBox).Clear()
                    End If
                Next
            End If
        Next
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
End Class